<?php
/**
 * $Id: mod_rewrite.php 12 2010-11-28 20:02:53Z LEON $
 * $Author: LEON $
 * $LastChangedDate: 2010-11-28 20:02:53 +0000 (Sun, 28 Nov 2010) $
 * $Revision: 12 $
 */
namespace cmFly\system\router;
class mod_rewrite extends base {
    protected function init() {
	$self=dirname(substr($_SERVER['SCRIPT_FILENAME'],strlen($_SERVER['DOCUMENT_ROOT'])));
	$doc_root_uri=str_replace("\\","/",$self);
	if(substr($doc_root_uri,-1)!='/') {
	    $doc_root_uri.='/';
	}
	$this->set_document_root_uri($doc_root_uri);

	$req_uri=preg_replace("#^(.*?)\?.*$#","$1",$_SERVER['REQUEST_URI']);
	$req_uri=str_replace(Array("%60","+"),Array("'"," "),rawurldecode($req_uri));

	$this->set_req_file_name($req_uri);
	$this->set_req_dir(preg_replace("#^(.*?/)[^/]*$#","$1",$req_uri));

	$cmd=substr($req_uri,strlen($self));
	if($cmd=='index.php') {
	    $cmd='/';
	}
	$this->set_args($this->parse_internal_path($cmd));
    }
}
?>